/* eslint-disable vue/no-unused-vars */
<template>
  <div id="management-div" :style="{backgroundImage:'url(' + total_menu + ')'}">
    <div class="qstb-div lists" @click="skipToQstb('mainv3', limitData[0])">
      <a href="#" class="box">
        <img :src="qstb_bg" alt="">
      </a>
    </div>
    <div class="dzzh-div lists" @click="skipTo('grid', 'gridselectnew', limitData[1])">
      <a href="#" class="box">
        <img :src="dzzh_bg" alt="">
      </a>
    </div>
    <div class="yqfk-div lists" @click="skipTo('yiqing', 'mainv3', limitData[2])">
      <a href="#" class="box">
        <img :src="yqfk_bg" alt="">
      </a>
    </div>
<!--    人员管理-->
    <div class="rygl-div lists" @click="skipTo('people', 'people', limitData[3])">
      <a href="#" class="box">
        <img :src="rygl_bg" alt="">
      </a>
    </div>
    <div class="logout-div" @click="modal10 = true">
      <img :src="logout_img" alt="">
    </div>
    <Modal id="tcdl" v-model="modal10" @on-ok="logout" width="350" class-name="vertical-center-modal">
        <p>您确定要退出登录吗？</p>
    </Modal>
    <!-- <div class="lists">
      <a href="#" class="box">
        <img :src="logout">
      </a>
      <a href="#" class="box">
        <img :src="logout">
      </a>
    </div> -->
  </div>
</template>

<script>
import './index.less'
import qstb_bg from '@/assets/summary/全市通办.png'
import dzzh_bg from '@/assets/summary/电子装户.png'
import yqfk_bg from '@/assets/summary/疫情防控.png'
import rygl_bg from '@/assets/summary/人员管理.png'
import logout_img from '@/assets/summary/quit.png'
import { mapActions } from 'vuex'
import { localClear } from '@/libs/util'
import xeUtils from 'xe-utils'
import total_menu from '@/assets/summary/total_menu.jpeg'
import total_menuas from '@/assets/summary/total_menuas.jpeg'
// import Gmk from '@/view/summary_login/Gmk.vue'
export default {
  name: 'indexv3',
  components: {
  },
  data () {
    return {
      total_menu,
      total_menuas,
      limitData: [],
      modal10: false,
      logout_img,
      login_url: '',
      qstb_bg,
      dzzh_bg,
      yqfk_bg,
      rygl_bg
    }
  },
  created () {
    // 鞍山环境下 修改logo
    if (xeUtils.locat().origin.includes('anshantb')) {
      this.total_menu = this.total_menuas
    }
  },
  computed: {
    limit_system () {
      return this.$store.state.user.severUserInfo.limit_system
    }
  },
  methods: {
    ...mapActions([
      'handleLogOut'
    ]),
    logout () {
      this.handleLogOut().then(() => {
        clearInterval(this.timerInterval)
        localClear()
        // this.token = localStorage.getItem('token')
        // localStorage.setItem('token', this.token)
        this.$router.push({
          name: 'login'
        })
      })
    },
    skipToQstb (url, flag) { // 全市通办跳转
      if (flag === true) {
        if (this.login_url.indexOf('http://qstb') !== -1) { // 生产环境 {
          window.open('http://qstb.mzj.shenyang.gov.cn/#/mainv3')
        } else {
          this.$router.push({ name: url })
        }
      } else {
        this.$Message.warning('无此系统权限,不可跳转')
      }
    },
    skipTo (url, menu, flag) { // 其他系统跳转
      if (flag === true) {
        if (this.login_url.indexOf('http://qstb') !== -1) { // 生产环境
          window.open('http://qstb.mzj.shenyang.gov.cn/' + url + '/#/' + menu)
        } else if (this.login_url.indexOf('http://iview.tripln.top') !== -1) { // 测试环境
          window.open('http://iview.tripln.top/' + url + '/#/' + menu)
        } else { // 本地
          // console.log('不跳转')
          this.$router.push({ name: url })
        }
      } else {
        this.$Message.warning('无此系统权限,不可跳转')
      }
    }
  },
  mounted () {
    this.login_url = window.location.href
    console.log(this.login_url, this.limit_system, '@@@')
    console.log(this.limit_system.split(','))
    if (this.limit_system.indexOf('csc') !== -1) {
      this.limitData[0] = true
    } else {
      this.limitData[0] = false
    }
    if (this.limit_system.indexOf('grid') !== -1) {
      this.limitData[1] = true
    } else {
      this.limitData[1] = false
    }
    if (this.limit_system.indexOf('xgc') !== -1) {
      this.limitData[2] = true
    } else {
      this.limitData[2] = false
    }
    if (this.limit_system.indexOf('worker') !== -1) {
      this.limitData[3] = true
    } else {
      this.limitData[3] = false
    }
    console.log(this.limitData, '@@@')
    // var limitStr = this.limit_system.indexOf('csc')
    // if (this.limit_system) {
    //   this.limitData = this.limit_system.split(',')
    // }
  }
}
</script>
